﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

namespace AutoInsurance
{
    public partial class newClient : System.Web.UI.Page
    {
        private string Сon = @"Data Source=LOCALHOST\SQLEXPRESS;Initial Catalog=AUTOINSURANCE;
Integrated Security=True;Pooling=False";

        protected void Page_Load(object sender, EventArgs e)
        {

        }
        //добавляем нового клиента
        protected void Button4_Click(object sender, EventArgs e)
        {
            try
            {
                SqlConnection connection = new SqlConnection(Сon);
                connection.Open();

                SqlCommand newClient = new SqlCommand("insert into Client (ratings,birthdate, name, surname, phone)" +
                    "VALUES ('" + TextBox3.Text + "','" + Convert.ToDateTime(TextBox7.Text) + "','" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox6.Text + "')", connection);
                newClient.ExecuteNonQuery();

                connection.Close();
                Label1.Visible = true;
                TextBox1.Text = "";
                TextBox2.Text = "";
                TextBox3.Text = "";
                TextBox7.Text = "";
                TextBox6.Text = "";
            }
            catch (Exception ex)
            {
                Server.Transfer("Error.aspx?error=" + ex.Message);

            }

        }

        
    }
}